class Solution {
public:
    int largestSumAfterKNegations(vector<int>& nums, int k) {
        sort(nums.begin(), nums.end());

        int i = 0;
        while(i < nums.size())
        {
            if(k > 0 && nums[i] < 0)
            {
                cout << 's';
                k--;
                nums[i] *= -1;
            }
            else if(nums[i] >= 0)
                break;
            
            i++;
        }
        cout << endl;
        cout << "i = " << i << ' '<< endl;

        if(k % 2 == 1)
        {
            nums[i] *= -1;
        }
        int sum = 0;
        for(auto e : nums)
        {
            cout << e << ' ';
            sum += e;
        }

        return sum;
    }
};

[-8,3,-5,-3,-5,-2]
-8 -5 -5 -3 -2 3
